package com.zhengke.service;

import java.io.IOException;
import java.util.List;

import com.zhengke.common.util.tools.LoadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhengke.dao.IndexDao;
import com.zhengke.pojo.IndexPic;
import com.zhengke.pojo.Order;
import com.zhengke.pojo.SysDictionaryItem;

@Service
public class IndexServiceImpl implements IndexService {
    @Autowired
    IndexDao ido;

    @Override
    public List<IndexPic> selectPic() {
        String fileServerUrl = null;
        try {
            fileServerUrl = LoadProperties.findValue("FILE_SERVER_URL");
        } catch (IOException e) {
            e.printStackTrace();
        }
        List<IndexPic> indexPics = ido.selectPic();
        for (IndexPic indexPic : indexPics) {
            String picPath = indexPic.getPicPath();
            indexPic.setPicPath(fileServerUrl + picPath);
            String defaultPic = indexPic.getDefaultPic();
            indexPic.setDefaultPic("viewRelative.do?path=" + defaultPic);
        }
        return indexPics;
    }

    @Override
    public List<Order> selectOrderByUserId(String paramString) {
        List<Order> orders = ido.selectOrderByUserId(paramString);
        return orders;
    }

    @Override
    public List<SysDictionaryItem> selectSysDictionaryItemByDicId(String paramString) {
		List<SysDictionaryItem> sysDictionaryItems = ido.selectSysDictionaryItemByDicId(paramString);
		return sysDictionaryItems;
    }

}
